/*
 * Bolygo.cc
 *
 *  Created on: 2009.12.14.
 *      Author: zsanka
 */

#include "Bolygo.hh"

using namespace Gui;
using namespace Network;

QImage Bolygo::img("img/bolygo.jpg");

Bolygo::Bolygo(QWidget* parent, StateChanged::PlanetInfo& pi):
	QWidget(parent),
	planetinfo(pi)
{
		resize(32, 32);
}

void Bolygo::mousePressEvent(QMouseEvent* ev) {
    if (ev->buttons() & Qt::LeftButton) {
        qDebug("signal! Bolygo::left_clicked");
        emit left_clicked(this);
    }

    if (ev->buttons() & Qt::RightButton) {
        qDebug("signal! Bolygo::right_clicked");
        emit right_clicked(this);
    }
}

void Bolygo::paintEvent(QPaintEvent* ev) {
	DONTCARE(ev);
	QPainter painter(this);
	QRect rect;
	rect.setSize(size());
	painter.drawImage(rect, img);
}

void Bolygo::select() {
    selected = true;
    repaint();
}

void Bolygo::deselect() {
    selected = false;
    repaint();
}

u8 Bolygo::get_id() const {
    return planetinfo.id;
}

QString Bolygo::get_player() const {
    return planetinfo.owner;
}
